package main

/*
   @Time : 2019/5/10 15:09 
   @Author : zpp

   cmd: go run demo2.go -name="zpp"
*/
import (
	"flag"
	"fmt"
)

var name string

func init() {
	//everyone: 未追加该命令参数时的默认值
	//The greeting object.: 命令参数的简短说明
	flag.StringVar(&name, "name", "everyone", "The greeting object.")
}

func introduce() string {
	return "Welcome to my Golang column."
}

func main() {
	//解析命令参数，把值赋值给相应的变量
	flag.Parse()
	fmt.Printf("Hello, %s!\n", name)

	//汉字由三个字节来表示，所以好的索引是爱的索引[3] + 3 = [6]
	str := "Go 爱好者 "
	for i, c := range str {
		fmt.Printf("%d: %q [% x]\n", i, c, []byte(string(c)))
	}
}
